// components/baoming_list_panel/baoming_list_panel.js
import ajax from "../../utils/ajax.js";
let app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    itemdata: {
      type: Object, 
      value: '', 
      observer(newVal, oldVal, changedPath) {
        console.log(newVal)
      }
    },
    itemstatus:{
      type: Object, 
      value: '', 
      observer(newVal, oldVal, changedPath) {
        console.log(newVal)
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    take_phone(e){
      wx.makePhoneCall({
        phoneNumber: e.currentTarget.dataset.phone+"" // 仅为示例，并非真实的电话号码
      })
    },
    quxiao_baoming(e){
      let that = this;
      let job_id = e.currentTarget.dataset.id
      wx.showModal({
        title: '温馨提示',
        content: '取消报名可能会影响您的信用等级，确认取消吗？',
        success(res) {
          if (res.confirm) {
            ajax.post({
              url:'parttime_jobs/cancel_enroll',
              data:{
                parttime_job_id:job_id
              }
            }).then(res=>{
              if(res.code==0){
                app.toast("已成功取消");
                
                // 更新列表

                // updatelist
                that.triggerEvent('updatelist', {}, {})
              }
            })
          } else if (res.cancel) {
            console.log('用户点击取消')
          }
        }
      })
    }
  }
})
